package cn.zc.mapper;

import cn.zc.entity.Cource;
import cn.zc.entity.CourceSQL;
import cn.zc.entity.LateTimeCource;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CourceMapper {
    //查看当前是第几周
    @Select("SELECT week_num FROM nowweek")
    int getWeek();

    void insertStudentCourse(List<CourceSQL> courceSQL);
    @Update("UPDATE student_courses SET isover = 3 where period=#{period} and day_of_week=#{dayOfWeekValue} and isover =0")
    void lateTime(int period, int dayOfWeekValue);
    @Select("SELECT * from student_courses where period=#{period} and day_of_week=#{dayOfWeekValue} and isover =3")
    @Results({
            @Result(property = "studentId", column = "student_id"),
    })
    List<LateTimeCource> selectlateTime(int period, int dayOfWeekValue);
    @Insert("insert into student_violations (student_id,violation_content,day_of_week,period,week) values (#{studentId},#{violation_content},#{dayOfWeek},#{period},#{week})")
    void addLateTimeCource(LateTimeCource lateTimeCource);
    @Update("UPDATE nowweek SET week_num = week_num + 1")
    void addWeek();
    @Select("SELECT * FROM student_courses WHERE student_id = #{id}")
    @Results({
            @Result(property = "studentId", column = "student_id"),
            @Result(property = "WeekType", column = "week_type"),
            @Result(property = "dayOfWeek", column = "day_of_week"),
    })
    List<CourceSQL> getcourcevoByid(String id);
    @Update("UPDATE student_courses set isover=0")
    void updateIsOver();
    @Select("SELECT * FROM student_courses WHERE student_id = #{id}")
    @Results({
            @Result(property = "studentId", column = "student_id"),
            @Result(property = "WeekType", column = "week_type"),
            @Result(property = "dayOfWeek", column = "day_of_week"),
    })
    List<CourceSQL> getCourceByUserId(String id);
    @Update("UPDATE student_courses set isover=#{isover} where day_of_week =#{dayOfWeek} and student_id =#{studentId} and period =#{period}")
    void upUserIsover(CourceSQL courceSQL);
}
